package com.normal.practise.controller;


import com.normal.practise.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@Api(tags = "登录接口")
//@CrossOrigin
@RestController
@RequestMapping("/api/user")
public class LoginController {
    /**
     * 登录
     * @return
     */
    @ApiOperation(value = "登录")
    @PostMapping("login")
    public ResponseResult login() {
        HashMap<String, String> map = new HashMap<>();
        map.put("token","admin");
        return ResponseResult.successResult(map);
    }

    /**
     * 获取用户信息
     * @return
     */
    @ApiOperation(value = "获取用户信息")
    @GetMapping("info")
    public ResponseResult info() {
        HashMap<String, String> map = new HashMap<>();
        map.put("roles","[admin,1]");
        map.put("name","admin");
        map.put("avatar","https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg");
        map.put("introduction","introduction");
        return ResponseResult.successResult(map);
    }

    /**
     * 退出
     * @return
     */
    @ApiOperation(value = "退出")
    @PostMapping("logout")
    public ResponseResult logout(){
        return ResponseResult.successResult();
    }
}
